package com.yiqi.zhiyuan.feature.msg.view.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yiqi.zhiyuan.R;
import com.yiqi.zhiyuan.entity.enums.MsgType;
import com.yiqi.zhiyuan.entity.vo.MessageTypeVO;
import com.yiqi.zhiyuan.entity.vo.MsgVO;

/**
 * @ProjectName: ZhiYuan
 * @Description: java类作用描述
 * @Author: lijuwen
 * @CreateDate: 2019/4/3 17:16
 * @UpdateUser: 更新者
 * @UpdateDate: 2019/4/3 17:16
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class MessageAdapter extends BaseQuickAdapter<MessageTypeVO, BaseViewHolder> {


    private MsgVO msgVO;

    public MessageAdapter() {
        super(R.layout.item_message);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageTypeVO item) {
        helper.setText(R.id.tv_msg_date_notice, item.getCreateTime())
                .setText(R.id.tv_msg_title, MsgType.getName(item.getType()))
                .setImageResource(R.id.iv_msg_title, MsgType.getImgRes(item.getType()))
                .setText(R.id.tv_msg_content_notice, item.getContent());
//        ：0公告 1系统 2行程 3收益 ,
        if (msgVO != null) {
            switch (item.getType()) {
                case 0:
                    helper.setVisible(R.id.tv_msg_count,msgVO.getPostNum()>0);
                    helper.setText(R.id.tv_msg_count,msgVO.getPostNum()+"");
                    break;
                case 1:
                    helper.setVisible(R.id.tv_msg_count,msgVO.getSysNum()>0);
                    helper.setText(R.id.tv_msg_count,msgVO.getSysNum()+"");
                    break;
                case 2:
                    helper.setVisible(R.id.tv_msg_count,msgVO.getTravelNum()>0);
                    helper.setText(R.id.tv_msg_count,msgVO.getTravelNum()+"");
                    break;
                case 3:
                    helper.setVisible(R.id.tv_msg_count,msgVO.getIncomeNum()>0);
                    helper.setText(R.id.tv_msg_count,msgVO.getIncomeNum()+"");
                    break;

            }
        }
    }

    public void setMsgVO(MsgVO msgVO) {
        this.msgVO = msgVO;
        notifyDataSetChanged();
    }
}
